package com.match.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Record;

/**
 * 对系统异常时的统一处理
 */
public class GlobalExceptionInterceptor implements Interceptor {

	public void intercept(Invocation inv) {
		Controller controller = inv.getController();
		try {
			inv.invoke();
		} catch (Throwable e) {
			Record record = new Record();
			record.set("result", false);
			record.set("msg", e.getMessage());
			controller.renderJson(record);
		}

	}
}
